<template>
  <div @click="changeNowblog" :class="real_them">
    <div class="title">{{ this.title }}</div>
    <div class="footer">
      <div class="left">
        <div class="tag">
          <TagVue
            v-for="(i, index) of tag"
            :key="index"
            :name="i[0]"
            :color="i[1]"
          />
        </div>
        <div class="date">{{ date }}</div>
      </div>
      <div class="right">
        <i class="el-icon-thumb"></i> <span>{{ real_like }}</span>
        <i class="el-icon-chat-dot-square"></i> <span>{{ real_comment }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import TagVue from "./Tag.vue";
export default {
  name: "Blog_detail",
  components: { TagVue },
  props: {
    title: {
      type: String,
      required: true,
    },
    like: {
      type: Number,
      default: 0,
    },
    comment: {
      type: Number,
      default: 0,
    },
    tag: {
      type: Array,
      default: () => {
        return [["前端"], ["JS"], ["原创", "danger"]];
      },
    },
    date: {
      type: String,
      required: true,
    },
    self: {
      type: Object,
      require: true,
    },
  },
  computed: {
    real_like() {
      if (this.like > 999) {
        return "999+";
      }
      return this.like;
    },
    real_comment() {
      if (this.comment > 999) {
        return "999+";
      }
      return this.comment;
    },
    real_them() {
      let k = this.$store.state.skin;
      let m = k == true ? "light" : "dark";
      return "outer" + " " + m;
    },
  },
  methods: {
    changeNowblog() {
      this.$store.commit("setNowblog",this.self);
      if(this.$store.state.blog_list == "blog_lists"){
        this.$store.state.blog_list = "blog_list"
      }
      if(this.$store.state.blog_context =='blog_contexts'){
        this.$store.state.blog_context ='blog_context'
      }
    },
  },
};
</script>

<style lang="less" scoped>
@import "../main.less";

.light {
  transition: all 1s;
  .title {
    color: @fs_light_contain;
  }
  .footer {
    color: @fs_light_smcontain;
  }
  &:hover {
    background-color: @bg_light_blue;
  }
}
.dark {
  transition: all 1s;
  .title {
    color: @fs_dark_contain;
  }
  .footer {
    color: @fs_dark_smcontain;
  }
  &:hover {
    background-color: @bg_dark_blue;
  }
}
.outer {
  width: 100%;
  height: 11%;
  cursor: pointer;
  .title {
    font-weight: 500px;
    height: 60%;
    padding: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .footer {
    padding: 0 10px;
    height: 40%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      width: 60%;
      text-align: left;
      display: flex;
      align-items: center;
      font-size: 14px;
      justify-content: space-between;
      .tag {
        display: flex;
        align-items: center;
      }
      .date {
        width: auto;
      }
    }
    .right {
      text-align: right;
      width: 40%;
      span {
        font-size: 14px;
        margin-right: 10px;
      }
    }
  }
  &:hover {
    transition: all 1s;
  }
}
</style>